#ifdef USEJNI
#include "HRIR_JNI.h"
#include "type/Complex.h"
#include "HRIR.h"
using namespace yzrilyzr_dsp;
JNIEXPORT jlong JNICALL Java_yzrilyzr_dsp_HRIR_constructor(JNIEnv * env, jobject, jlongArray hrirs, jint azLength, jint elLength, jint channels, jint fftLength){
	jlong * elements=env->GetLongArrayElements(hrirs, nullptr);
	int32_t length=env->GetArrayLength(hrirs);
	if(elements == nullptr){
		std::cerr << "Buffer nullptr" << std::endl;
		return 0;
	}
	//Complex***** hrir1 = new Complex * ***[azLength];
	DoubleArray **** hrir1=new DoubleArray * **[azLength];
	for(u_index i=0; i < azLength; i++){
		hrir1[i]=new DoubleArray * *[elLength];
		//hrir1[i] = new Complex * **[elLength];
		for(u_index j=0; j < elLength; j++){
			hrir1[i][j]=new DoubleArray * [channels];
			//hrir1[i][j] = new Complex * *[channels];
			for(u_index k=0; k < channels; k++){
				//hrir1[i][j][k] = reinterpret_cast<Complex**>(elements[i*elLength + j * channels + k ]);
				hrir1[i][j][k]=reinterpret_cast<DoubleArray *>(elements[i * elLength + j * channels + k]);
			}
		}
	}
	env->ReleaseLongArrayElements(hrirs, elements, 0);
	HRIR * ptr=new HRIR(hrir1, azLength, elLength, channels, fftLength);
	return reinterpret_cast<jlong>(ptr);
}
JNIEXPORT void JNICALL Java_yzrilyzr_dsp_HRIR_setChannel(JNIEnv *, jobject, jlong ptr, jint channel){
	HRIR * ptr1=reinterpret_cast<HRIR *>(ptr);
	ptr1->setChannel(channel);
}
JNIEXPORT void JNICALL Java_yzrilyzr_dsp_HRIR_setPos(JNIEnv *, jobject, jlong ptr, jint az, jint el){
	HRIR * ptr1=reinterpret_cast<HRIR *>(ptr);
	ptr1->setPos(az, el);
}
#endif